// SilverlightControlToolkit.SampleScripts.js
//


Type.registerNamespace('SilverlightControlToolkit.SampleScripts');

////////////////////////////////////////////////////////////////////////////////
// SilverlightControlToolkit.SampleScripts.SampleManager

SilverlightControlToolkit.SampleScripts.SampleManager = function SilverlightControlToolkit_SampleScripts_SampleManager(host) {
    SilverlightControlToolkit.SampleScripts.SampleManager.initializeBase(this, [ host ]);
}
SilverlightControlToolkit.SampleScripts.SampleManager.prototype = {
    m_myBtn: null,
    m_myBtn1: null,
    m_myBtn2: null,
    m_toggle: null,
    m_tbList: null,
    m_tbList2: null,
    m_debugBox: null,
    
    onSilverlightLoaded: function SilverlightControlToolkit_SampleScripts_SampleManager$onSilverlightLoaded(slControl, args) {
        this.m_debugBox = this.get_plugin().content.findName('txtDebug');
        var mouseEnterTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        mouseEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_textBlock\" Storyboard.TargetProperty=\"(TextBlock.Foreground).(SolidColorBrush.Color)\">';
        mouseEnterTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.6000000\" Value=\"#FF00FF00\"/>';
        mouseEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        mouseEnterTemplate += '</Storyboard>';
        var mouseLeaveTemplate = '<Storyboard  xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        mouseLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_textBlock\" Storyboard.TargetProperty=\"(TextBlock.Foreground).(SolidColorBrush.Color)\">';
        mouseLeaveTemplate += '\t<SplineColorKeyFrame KeyTime=\"00:00:00.6000000\" Value=\"#FF000000\"/>';
        mouseLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        mouseLeaveTemplate += '</Storyboard>';
        var mouseDownTemplate = '<Storyboard  xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"  x:Name=\"$name$\">';
        mouseDownTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangle\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">';
        mouseDownTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.1000000\" Value=\"#FFF2FF00\"/>';
        mouseDownTemplate += '</ColorAnimationUsingKeyFrames>';
        mouseDownTemplate += '</Storyboard>';
        var mouseUpTemplate = '<Storyboard  xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"  x:Name=\"$name$\">';
        mouseUpTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangle\" Storyboard.TargetProperty=\"(Shape.Fill).(SolidColorBrush.Color)\">';
        mouseUpTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.1000000\" Value=\"#FFFF0000\"/>';
        mouseUpTemplate += '</ColorAnimationUsingKeyFrames>';
        mouseUpTemplate += '</Storyboard>';
        var radioEnterTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        radioEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellipseOuter\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        radioEnterTemplate += '\t<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF4E6D78\"/>';
        radioEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        radioEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeInner\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        radioEnterTemplate += '\t<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF6F9EAF\"/>';
        radioEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        radioEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeInner\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)\">';
        radioEnterTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF8E9DC7\"/>';
        radioEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        radioEnterTemplate += '</Storyboard>';
        var radioLeaveTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        radioLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellipseOuter\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        radioLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF767676\"/>';
        radioLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        radioLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeInner\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        radioLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FFADADAD\"/>';
        radioLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        radioLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeInner\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)\">';
        radioLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FFC8C8C8\"/>';
        radioLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        radioLeaveTemplate += '</Storyboard>';
        var radioDownTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        radioDownTemplate += '<DoubleAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeSelector\" Storyboard.TargetProperty=\"(UIElement.Opacity)\">';
        radioDownTemplate += '<SplineDoubleKeyFrame KeyTime=\"00:00:00.2000000\" Value=\"1\"/>';
        radioDownTemplate += '</DoubleAnimationUsingKeyFrames>';
        radioDownTemplate += '</Storyboard>';
        var radioUpTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        radioUpTemplate += '<DoubleAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_ellispeSelector\" Storyboard.TargetProperty=\"(UIElement.Opacity)\">';
        radioUpTemplate += '<SplineDoubleKeyFrame KeyTime=\"00:00:00.2000000\" Value=\"0\"/>';
        radioUpTemplate += '</DoubleAnimationUsingKeyFrames>';
        radioUpTemplate += '</Storyboard>';
        var checkEnterTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        checkEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleOuter\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        checkEnterTemplate += '\t<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF4E6D78\"/>';
        checkEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        checkEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleInner\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        checkEnterTemplate += '\t<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF6F9EAF\"/>';
        checkEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        checkEnterTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleInner\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)\">';
        checkEnterTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF8E9DC7\"/>';
        checkEnterTemplate += '</ColorAnimationUsingKeyFrames>';
        checkEnterTemplate += '</Storyboard>';
        var checkLeaveTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        checkLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleOuter\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        checkLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FF767676\"/>';
        checkLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        checkLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleInner\" Storyboard.TargetProperty=\"(Shape.Stroke).(SolidColorBrush.Color)\">';
        checkLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FFADADAD\"/>';
        checkLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        checkLeaveTemplate += '<ColorAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_rectangleInner\" Storyboard.TargetProperty=\"(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)\">';
        checkLeaveTemplate += '<SplineColorKeyFrame KeyTime=\"00:00:00.3000000\" Value=\"#FFC8C8C8\"/>';
        checkLeaveTemplate += '</ColorAnimationUsingKeyFrames>';
        checkLeaveTemplate += '</Storyboard>';
        var checkDownTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        checkDownTemplate += '<DoubleAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_pathSelector\" Storyboard.TargetProperty=\"(UIElement.Opacity)\">';
        checkDownTemplate += '<SplineDoubleKeyFrame KeyTime=\"00:00:00.2000000\" Value=\"1\"/>';
        checkDownTemplate += '</DoubleAnimationUsingKeyFrames>';
        checkDownTemplate += '</Storyboard>';
        var checkUpTemplate = '<Storyboard xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"$name$\">';
        checkUpTemplate += '<DoubleAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"$targetname$_pathSelector\" Storyboard.TargetProperty=\"(UIElement.Opacity)\">';
        checkUpTemplate += '<SplineDoubleKeyFrame KeyTime=\"00:00:00.2000000\" Value=\"0\"/>';
        checkUpTemplate += '</DoubleAnimationUsingKeyFrames>';
        checkUpTemplate += '</Storyboard>';
        SilverlightControlToolkit.SampleScripts.SampleManager.callBaseMethod(this, 'onSilverlightLoaded', [ slControl, args ]);
        $create(SilverlightControlToolkit.Button,{'plugin' : this.get_plugin(),
                                                                                                        'elementName':'MyButton',
                                                                                                        'mouseEnterTemplate':mouseEnterTemplate,
                                                                                                        'mouseLeaveTemplate':mouseLeaveTemplate,
                                                                                                        'mouseDownTemplate':mouseDownTemplate,
                                                                                                        'mouseUpTemplate':mouseUpTemplate},
                                                                                                       {'click':Function.createDelegate(this, this.onBtnClick)},
                                                                                                       null,null);
        /*this.m_myBtn = new SilverlightControlToolkit.Button();
        this.m_myBtn.set_plugin(this.get_plugin());
        this.m_myBtn.set_elementName('MyButton');
        this.m_myBtn.add_click(Function.createDelegate(this, this.onBtnClick));
        this.m_myBtn.set_mouseEnterTemplate(mouseEnterTemplate);
        this.m_myBtn.set_mouseLeaveTemplate(mouseLeaveTemplate);
        this.m_myBtn.set_mouseDownTemplate(mouseDownTemplate);
        this.m_myBtn.set_mouseUpTemplate(mouseUpTemplate);
        this.m_myBtn.initialize();
        Sys.Application.addComponent(this.m_myBtn);*/
        this.m_myBtn1 = new SilverlightControlToolkit.Button();
        this.m_myBtn1.set_plugin(this.get_plugin());
        this.m_myBtn1.set_elementName('MyButton1');
        this.m_myBtn1.add_click(Function.createDelegate(this, this.onBtnClick));
        this.m_myBtn1.set_mouseEnterTemplate(mouseEnterTemplate);
        this.m_myBtn1.set_mouseLeaveTemplate(mouseLeaveTemplate);
        this.m_myBtn1.set_mouseDownTemplate(mouseDownTemplate);
        this.m_myBtn1.set_mouseUpTemplate(mouseUpTemplate);
        this.m_myBtn1.initialize();
        Sys.Application.addComponent(this.m_myBtn1);
        this.m_myBtn2 = new SilverlightControlToolkit.Button();
        this.m_myBtn2.set_plugin(this.get_plugin());
        this.m_myBtn2.set_elementName('MyButton2');
        this.m_myBtn2.add_click(Function.createDelegate(this, this.onBtnClick));
        this.m_myBtn2.set_mouseEnterTemplate(mouseEnterTemplate);
        this.m_myBtn2.set_mouseLeaveTemplate(mouseLeaveTemplate);
        this.m_myBtn2.set_mouseDownTemplate(mouseDownTemplate);
        this.m_myBtn2.set_mouseUpTemplate(mouseUpTemplate);
        this.m_myBtn2.initialize();
        Sys.Application.addComponent(this.m_myBtn2);
        this.m_toggle = new SilverlightControlToolkit.ToggleButton();
        this.m_toggle.set_plugin(this.get_plugin());
        this.m_toggle.set_elementName('ToggleButton');
        this.m_toggle.add_click(Function.createDelegate(this, this.onBtnClick));
        this.m_toggle.add_pushed(Function.createDelegate(this, this.onPushed));
        this.m_toggle.add_unpushed(Function.createDelegate(this, this.onUnPushed));
        this.m_toggle.set_mouseEnterTemplate(mouseEnterTemplate);
        this.m_toggle.set_mouseLeaveTemplate(mouseLeaveTemplate);
        this.m_toggle.set_mouseDownTemplate(mouseDownTemplate);
        this.m_toggle.set_mouseUpTemplate(mouseUpTemplate);
        this.m_toggle.initialize();
        Sys.Application.addComponent(this.m_toggle);
        var toggleButtons = [];
        for (var i = 0; i < 4; i++) {
            var tb = new SilverlightControlToolkit.ToggleButton();
            tb.set_plugin(this.get_plugin());
            tb.set_elementName('Radio' + i.toString());
            tb.set_mouseEnterTemplate(radioEnterTemplate);
            tb.set_mouseLeaveTemplate(radioLeaveTemplate);
            tb.set_mouseDownTemplate(radioDownTemplate);
            tb.set_mouseUpTemplate(radioUpTemplate);
            tb.initialize();
            Sys.Application.addComponent(tb);
            Array.add(toggleButtons, tb);
        }
        this.m_tbList = new SilverlightControlToolkit.ToggleButtonList();
        this.m_tbList.set_plugin(this.get_plugin());
        this.m_tbList.set_items(toggleButtons);
        this.m_tbList.set_behavior(SilverlightControlToolkit.ToggleButtonListBehavior.radioButtonList);
        this.m_tbList.set_id('ToggleButtonList0');
        this.m_tbList.initialize();
        this.m_tbList.add_selectionChanged(Function.createDelegate(this, this.onSelectionChanged));
        Sys.Application.addComponent(this.m_tbList);
        var checks = [];
        for (var i = 0; i < 4; i++) {
            var tb = new SilverlightControlToolkit.ToggleButton();
            tb.set_plugin(this.get_plugin());
            tb.set_elementName('Check' + i.toString());
            tb.set_mouseEnterTemplate(checkEnterTemplate);
            tb.set_mouseLeaveTemplate(checkLeaveTemplate);
            tb.set_mouseDownTemplate(checkDownTemplate);
            tb.set_mouseUpTemplate(checkUpTemplate);
            tb.initialize();
            Sys.Application.addComponent(tb);
            Array.add(checks, tb);
        }
        this.m_tbList2 = new SilverlightControlToolkit.ToggleButtonList();
        this.m_tbList2.set_plugin(this.get_plugin());
        this.m_tbList2.set_items(checks);
        this.m_tbList2.set_behavior(SilverlightControlToolkit.ToggleButtonListBehavior.checkboxButtonList);
        this.m_tbList2.set_id('ToggleButtonList1');
        this.m_tbList2.initialize();
        this.m_tbList2.add_selectionChanged(Function.createDelegate(this, this.onSelectionChanged));
        Sys.Application.addComponent(this.m_tbList2);
    },
    
    onSelectionChanged: function SilverlightControlToolkit_SampleScripts_SampleManager$onSelectionChanged(sender, args) {
        var selection = (sender).get_selectedItems();
        var sb = new Sys.StringBuilder();
        for (var i = 0; i < selection.length; i++) {
            sb.append((selection[i]).get_id() + ';');
        }
        this.m_debugBox.text = sb.toString();
    },
    
    onBtnClick: function SilverlightControlToolkit_SampleScripts_SampleManager$onBtnClick(sender, args) {
        this.m_debugBox.text = 'Click ! ' + (sender).get_id();
    },
    
    onPushed: function SilverlightControlToolkit_SampleScripts_SampleManager$onPushed(sender, args) {
        this.m_debugBox.text = 'Pushed !';
    },
    
    onUnPushed: function SilverlightControlToolkit_SampleScripts_SampleManager$onUnPushed(sender, args) {
        this.m_debugBox.text = 'UnPushed !';
    }
}


SilverlightControlToolkit.SampleScripts.SampleManager.registerClass('SilverlightControlToolkit.SampleScripts.SampleManager', SilverlightControlToolkit.SLManager);

// ---- Do not remove this footer ----
// Generated using Script# v0.4.2.0 (http://projects.nikhilk.net)
// -----------------------------------
